package com.news.cloud.service;

import com.news.cloud.exception.ServerTechnicalException;
import com.news.cloud.jpa.domain.Channel;
import com.news.cloud.jpa.repository.ChannelRepository;
import com.news.cloud.web.model.ChannelPageResponse;
import com.news.cloud.web.model.ChannelResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by hiephn on 2014/09/01.
 */
@Service
public class ChannelService {

    @Autowired
    private ChannelRepository channelRepo;

    public ChannelPageResponse get() throws ServerTechnicalException {
        List<Channel> channels = channelRepo.findAll();
        ChannelPageResponse channelPageResponse = new ChannelPageResponse();
        channelPageResponse.from(channels, ChannelResponse.class);
        return channelPageResponse;
    }
}
